﻿@using Kairos
@using Kairos.Controllers

@model IEnumerable<Kairos.Models.Vtom>

@{
    ViewBag.Title = "Jobs Vtom";
}

<h2>Jobs Vtom</h2>

@if (Model.Count() != 0)
{
    using (Html.BeginForm("Create", "CookieVtomJobs"))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <fieldset>
            <legend>Vtoms</legend>

            <table align="center" width="100%">
                <tr>
                    <td colspan="2">
                        <div class="content-wrapper">
                            @Html.TextBox("filter", ViewBag.Filter as string, new { @class = "search ui-corner-all" })
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="submit" value="Filtrer" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />
                    </td>
                </tr>
            </table>

        </fieldset>
    }
}

@if (Model.Count() == 0)
{
    <p>
        Aucun job Vtom
    </p>
}
else
{
    <table>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    Le job <mark class="ui-corner-all">@Html.DisplayFor(modelItem => item.Titre)</mark> est assigné à la consigne
                    @{
                    var _routes = 
                        new RouteValueDictionary(new { id = item.DocID }).AddRange(item.Variables.GetQuerystring());

                    @Html.ActionLink(
                        Url.Action("Details", "Doc", _routes),
                        "Details",
                        "Doc",
                        _routes,
                        HtmlHelper.AnonymousObjectToHtmlAttributes(new { target = "_blank" }));
                    }
                </td>
                @if (ViewBag.ShouldDisplayUI(Kairos.Roles.Administrator | Kairos.Roles.Worker))
                {
                    <td>
                        @Html.ActionLink("Editer", "Edit", new { id = item.ID, reason = Reason.Standard })
                    </td>
                }
            </tr>
        }
    </table>

    @Html.Partial("_Pager")
}
